﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfAddVehicle.aspx.cs" Inherits="msBsc.WebUi.wMall.Seller.wfAddVehicle" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>添加车辆</title>
    <link href="/themes/wStyle1/css/sLayout.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sHead.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sFoot.css" rel="stylesheet" />
    <link href="/jqPlugin/laydate/skins/default/laydate.css" rel="stylesheet" />
    <link href="/jqPlugin/SelectSimu/css/base.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/from.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/Seller/sAddVehicle.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/Seller/loadFileLayout.css" rel="stylesheet" />

    <link href="/themes/wStyle1/css/usermenu.css" rel="stylesheet" />
</head>
<body>
    <div class="wf_all">
        <div id="divLoginInfo">
            <%=msBsc.WebUi.Code.QtHtmlGet.GetHeaderLoginInfo() %>
        </div>
        <div class="main-container">
            <div class="sidebar-scroll">
                <%=msBsc.WebUi.Code.QtHtmlGet.GetDjackMenuHtml() %>
            </div>
            <div class="main-Info">
                <div class="tnavigation">
                    <a href="#" class="nav">我的地接客</a>&gt;
			
                    <a href="#" class="nav">车辆管理</a>&gt;
			
                    <a href="#" class="nav-on">添加车辆</a>
                </div>
                <hr />
                <ul class="main-horizontal">
                    <!-- BEGIN 车辆图片 -->
                    <li>
                        <span class="control-span">车辆图片<span class="required">*</span></span>
                        <div class="controls">
                            <div style="display: inline; float: left;">
                                <table border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <div id="logo_img_selected">
                                                <img id="uHeadImg" src="/themes/Style1/Image/u_head_110x110.png" for="" />
                                            </div>
                                        </td>
                                        <td style="padding: 3px;">
                                            <div style="padding: 5px;">
                                                <a id="btnupImg" target="_self" value="上传图片" style="margin: 6px; cursor: pointer;" onclick="javascript:return false;">上传图片</a>
                                                <p>
                                                    建议图片大小： 220 x 110 (像素)，文件大小不能大于1M
                                                </p>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="carImgMessage" class="help-inline"></div>
                        </div>
                    </li>
                    <!-- END 车辆图片 -->
                    <!-- BEGIN 车辆名称 -->
                    <li>
                        <span class="control-span">车辆名称<span class="required">*</span></span><div class="controls">
                            <input type="text" id="carName" class="input" />
                            <span id="carNameMessage" class="help-inline"></span>
                        </div>
                    </li>
                    <!-- END 车辆名称 -->

                    <!-- BEGIN 车辆购买时间 -->
                    <li>
                        <span class="control-span">购买时间<span class="required">*</span></span><div class="controls">
                            <input type="text" id="uetoTime" class="input laydate-icon" style="width: 218px" />
                            <span id="uetoTimeMessage" class="help-inline"></span>
                        </div>
                    </li>
                    <!-- END 车辆购买时间 -->

                    <!-- BEGIN 车辆座位数 -->
                    <li>
                        <span class="control-span">座位数(座)<span class="required">*</span></span><div class="controls">
                            <input type="text" id="numberSeats" class="input" />
                            <span id="numberSeatsMessage" class="help-inline"></span>
                        </div>
                    </li>
                    <!-- END 车辆座位数 -->

                    <!-- BEGIN 车辆价格 -->
                    <li>
                        <span class="control-span">价格(元/天起)<span class="required">*</span></span><div class="controls">
                            <input type="text" id="carPrice" class="input" />
                            <span id="carPriceMessage" class="help-inline"></span>
                        </div>
                    </li>
                    <!-- END 车辆价格 -->

                    <!-- BEGIN 服务范围 -->
                    <li>
                        <span class="control-span">服务范围<span class="required">*</span></span><div class="controls">
                            <input type="text" id="serviceRange" class="input" />
                            <span id="serviceRangeMessage" class="help-inline"></span>
                        </div>
                    </li>
                    <!-- END 服务范围 -->

                    <!-- BEGIN 车辆所属地 -->
                    <li>
                        <span class="control-span">所属地区<span class="required">*</span></span><div class="controls">
                            <div id="country" class="select selectFloat selectArea"></div>
                            <div id="city" class="select selectFloat selectArea"></div>
                            <div id="destion" class="select selectFloat selectArea"></div>
                            <span id="areaMessage" class="help-inline"></span>
                        </div>
                    </li>
                    <!-- END 车辆所属地 -->

                    <!-- BEGIN 车辆类型 -->
                    <li>
                        <span class="control-span">车辆类型<span class="required">*</span></span><div class="controls">
                            <div id="carType" class="select selectFloat"></div>
                            <span id="carTypeMessage" class="help-inline selectFloat"></span>
                        </div>
                    </li>
                    <!-- END 车辆类型 -->

                    <!-- BEGIN 车辆品牌 -->
                    <li>
                        <span class="control-span">车辆品牌<span class="required">*</span></span><div class="controls">
                            <div id="carBrand" class="select selectFloat"></div>
                            <span id="carBrandMessage" class="help-inline selectFloat"></span>
                        </div>
                    </li>
                    <!-- END 车辆品牌 -->

                    <!-- BEGIN 车辆颜色 -->
                    <li>
                        <span class="control-span">车辆颜色<span class="required">*</span></span><div class="controls">
                            <div id="carColor" class="select selectFloat"></div>
                            <span id="carColorMessage" class="help-inline selectFloat"></span>
                        </div>
                    </li>
                    <!-- END 车辆颜色 -->

                    <!-- BEGIN 服务类型 -->
                    <li>
                        <span class="control-span">服务类型<span class="required">*</span></span><div class="controls">
                            <div id="serviceType" class="select selectFloat"></div>
                            <span id="serviceTypeMessage" class="help-inline selectFloat"></span>
                        </div>
                    </li>
                    <!-- END 服务类型 -->

                    <!-- BEGIN 车辆简介 -->
                    <li>
                        <span class="control-span">车辆简介<span class="required">*</span></span><div class="controls">
                            <textarea id="carIntroduction" class="textarea-large"></textarea>
                            <span id="carIntroductionMessage" class="help-inline"></span>
                        </div>
                    </li>
                    <!-- END 车辆简介 -->

                    <!-- BEGIN 购买须知 -->
                    <li>
                        <span class="control-span">购买须知<span class="required">*</span></span><div class="controls">
                            <textarea id="purchaseNotes" class="textarea-large"></textarea>
                            <span id="purchaseNotesMessage" class="help-inline"></span>
                        </div>
                    </li>
                    <!-- END 购买须知 -->
                </ul>

                <!-- BEGIN 添加车辆按钮 -->
                <div class="form-actions">
                    <button type="button" class="btn blue" onclick="addVehicle(this)"><i class="icon-ok"></i>保 存</button>
                    <button type="button" class="btn" onclick="ResetCar()"><i class=" icon-remove"></i>重 置</button>
                </div>
                <!-- END 添加车辆按钮 -->
            </div>
        </div>

        <!--start JS引用-->
        <script src="/jqPlugin/js/jquery-1.8.3.min.js"></script>
        <script src="/jqPlugin/js/jBase.js"></script>
        <script src="/jqPlugin/js/jBPage.js"></script>
        <script src="/jqPlugin/js/laytpl.js"></script>
        <script src="/jqPlugin/laydate/laydate.js"></script>
        <script src="/themes/wStyle1/js/comm/VerifyJs.js"></script>
        <script src="/themes/wStyle1/js/comm/DateInfo.js"></script>

        <script src="/jqPlugin/SelectSimu/js/SelectSimu.js"></script>
        <script src="/themes/wStyle1/js/comm/jsLayout.js"></script>
        <!--end JS引用-->
        <script type="text/javascript">

            var start = {
                elem: '#uetoTime',
                format: 'YYYY-MM-DD',
                min: '1099-06-16 23:59:59', //设定最小日期为当前日期
                max: laydate.now(), //最大日期
                istime: true,
                istoday: false,
                choose: function (datas) {
                    //end.min = datas; //开始日选好后，重置结束日的最小日期
                    //end.start = datas //将结束日的初始值设定为开始日
                    computingPrice();
                }
            };
            laydate(start);
            var parentsId = "00000000-0000-0000-0000-000000000000";
            var currentOuterInnerId = "";
            var currentProvinceId = "";

            (function () {


                $.ploadFile("kindeditor", function (script, textStatus) {
                    $.setUploadFile('btnupImg', { FileId: '', RelId: "", rType1: '0', rType2: '' }, function (data) {
                        if (data.url) {
                            $('#logo_img_selected').empty().html('<img alt="" src="' + data.url + '" for="' + data.url + '">');
                        }
                    });
                });


                var listNum = [0, 1, 2, 3];
                var listName = ["请选择", "司机兼导游", "司机兼向导", "专职司机+专业导游"];
                setArea("serviceType", 234, 2, listNum.length, listNum, listName);
                $('#country .selectList li').live('click', function () {
                    var outerInnerId = this.getAttribute('data-value');
                    if (currentOuterInnerId == outerInnerId) {
                        return;
                    }
                    currentOuterInnerId = outerInnerId;
                    parentsId = outerInnerId;
                    btnDo("getArea2");
                });
                $('#city .selectList li').live('click', function () {
                    var provinceId = this.getAttribute('data-value');
                    if (provinceId == currentProvinceId) {
                        return;
                    }
                    currentProvinceId = provinceId;
                    parentsId = provinceId;
                    btnDo("getArea3");
                });
            })();
            function btnDo(sEbtn) {
                GtGrid1Action = sEbtn;
                var opart = GetGtParam("false");
                ajaxComm(opart);
            };

            function setArea(input, width, zIndex, listNum, listValue, listOption) {
                $("#" + input).SelectSimu({
                    width: width,
                    zIndex: zIndex,
                    listNum: listNum,
                    listValue: listValue,
                    listOption: listOption,
                    imgSrc: '/jqPlugin/SelectSimu/img/icon_down.png'
                })
            }

            function updateSelet(inputId, valueData) {
                var selectValue = $("#" + inputId + " .selectList ul");
                selectValue.html("");
                var data = eval(valueData);
                selectValue.append('<li data-value="0">请选择</li>');
                for (var i = 0; i < data.length; i++) {
                    selectValue.append('<li data-value="' + data[i].ID + '">' + data[i].Name + '</li>');
                }
                $("#" + inputId + " input").val(0);
                $("#" + inputId + " span").text("请选择");
            }

            //执行AJAX调用时获取参数
            function GetGtParam(isAll) {
                var _jsParam = new jsonRow();
                _jsParam.AddCell("parentsId", parentsId);
                _jsParam.AddCell("isAll", isAll);
                _jsParam.AddCell("ACTION", GtGrid1Action);
                return _jsParam;
            };


            btnDo("initplace");

            function addVehicle() {
                //验证车名
                var carName = $("#carName").val();
                if (!vfcCarName(carName)) {
                    return;
                }
                //验证上户时间
                var uetoTime = $("#uetoTime").val();
                if (!vfcUetoTime(uetoTime)) {
                    return;
                }
                //验证车辆座位数
                var numberSeats = $("#numberSeats").val();
                if (!vfcSeats(numberSeats)) {
                    return;
                }
                //验证价格
                var carPrice = $("#carPrice").val();
                if (!vfcPrice(carPrice)) {
                    return;
                }
                //验证服务范围
                var servicesRange = $("#serviceRange").val();
                if (!vfcRange(servicesRange)) {
                    return;
                }

                //验证车辆所属地
                var countryId = "";//境内外
                var cityId = "";//省份
                var destionId = "";//市
                countryId = $("#country input").val();
                cityId = $("#city input").val();
                destionId = $("#destion input").val();
                if (!vfcCarArea(countryId) || !vfcCarArea(cityId) || !vfcCarArea(destionId)) {
                    return;
                }

                //验证车辆类型
                var carType = $("#carType input").val();
                if (!vfcCarType(carType)) {
                    return;
                }
                //验证车辆品牌
                var carBrand = $("#carBrand input").val();
                if (!vfcBrand(carBrand)) {
                    return;
                }
                //验证车辆颜色
                var carColor = $("#carColor input").val();
                if (!vfcColor(carColor)) {
                    return;
                }
                //验证服务类型
                var serviceType = $("#serviceType input").val();
                if (!vfcServiceType(serviceType)) {
                    return;
                }
                //验证图片 
                var carImg = $("#logo_img_selected img").attr("for");
                if (!vfcImg(carImg)) {
                    return;
                }
                //var arrVehicleImg = carImg.split("/");
                //var carImg = arrVehicleImg[arrVehicleImg.length - 1];
                //验证简介
                var carIntroduction = $("#carIntroduction").val();
                if (!vfcIntroduction(carIntroduction)) {
                    return;
                }
                //验证购买须知
                var purchaseNotes = $("#purchaseNotes").val();
                if (!vfcNotes(purchaseNotes)) {
                    return;
                }


                var opart = new jsonRow();
                opart.AddCell("carName", carName);
                opart.AddCell("uetoTime", uetoTime);
                opart.AddCell("numberSeats", numberSeats);
                opart.AddCell("carPrice", carPrice);
                opart.AddCell("servicesRange", servicesRange);
                opart.AddCell("carType", carType);
                opart.AddCell("carBrand", carBrand);
                opart.AddCell("carColor", carColor);
                opart.AddCell("serviceType", serviceType);
                opart.AddCell("carImg", carImg);
                opart.AddCell("carIntroduction", carIntroduction);
                opart.AddCell("purchaseNotes", purchaseNotes);
                opart.AddCell("countryId", countryId);
                opart.AddCell("cityId", cityId);
                opart.AddCell("destionId", destionId);
                opart.AddCell("ACTION", "addVehicle");
                ajaxComm(opart);
            }

            //清空车辆信息
            function ResetCar() {
                $("#carName").val("");
                $("#uetoTime").val("");
                $("#numberSeats").val("");
                $("#serviceRange").val("");
                $("#carPrice").val("");
                $("#carIntroduction").val("");
                $("#purchaseNotes").val("");
                $("#logo_img_selected img").attr("for", "");
                $("#logo_img_selected img").attr("src", "/themes/Style1/Image/u_head_110x110.png");
            }

            //验证车名
            function vfcCarName(carName) {
                if (IsNull(carName)) {
                    alert("车名不能为空");
                    return false;
                }
                if (!isEnLength(carName, 0, 40)) {
                    alert("车名最大长度为40个字符，中文算2个字符");
                    return false;
                }
                return true;
            }

            //验证车辆所属地
            function vfcCarArea(areaId) {
                if (IsNull(areaId) || areaId == "0") {
                    alert("所属地区不能为空");
                    return false;
                }
                return true;
            }

            //验证上户时间
            function vfcUetoTime(uetoTime) {
                if (IsNull(uetoTime)) {
                    alert("购买时间不能为空");
                    return false;
                }
                if (!isdate(uetoTime)) {
                    alert("购买时间只能是日期");
                    return false;
                }
                return true;
            }

            //验证车辆类型
            function vfcCarType(carType) {
                if (IsNull(carType) || carType == "0") {
                    alert("车辆类型不能为空");
                    return false;
                }
                return true;
            }

            //验证车辆座位数
            function vfcSeats(numberSeats) {
                if (IsNull(numberSeats)) {
                    alert("车辆座位数不能为空");
                    return false;
                }
                if (!NonzeroPositiveInt(numberSeats)) {
                    alert("车辆座位数只能是正整数");
                    return false;
                }
                return true;
            }

            //验证服务范围
            function vfcRange(serviceRange) {
                if (IsNull(serviceRange)) {
                    alert("服务范围不能为空");
                    return false;
                }
                if (!islength(serviceRange, 0, 200)) {
                    alert("服务范围最大长度为200个字符");
                    return false;
                }
                return true;
            }

            //验证服务类型
            function vfcServiceType(serverType) {
                if (IsNull(serverType)) {
                    alert("服务类型不能为空");
                    return false;
                }
                if (serverType == 0) {
                    alert("请选择服务类型");
                    return;
                }
                return true;
            }

            //验证车辆品牌
            function vfcBrand(carBrand) {
                if (IsNull(carBrand) || carBrand == "0") {
                    alert("车辆品牌不能为空");
                    return false;
                }
                return true;
            }

            //验证价格
            function vfcPrice(carPrice) {
                if (IsNull(carPrice)) {
                    alert("价格只能是两位小数的数字");
                    return false;
                }
                if (!IsPositiveFloat(carPrice)) {
                    alert("价格只能是数字");
                    return false;
                }
                return true;
            }

            //验证颜色
            function vfcColor(carColor) {
                if (IsNull(carColor) || carColor == "0") {
                    alert("车辆颜色不能为空");
                    return false;
                }
                return true;
            }

            //验证车辆图片
            function vfcImg(carImg) {
                if (IsNull(carImg)) {
                    alert("车辆图片不能为空");
                    return false;
                }
                return true;
            }

            //验证车辆简介
            function vfcIntroduction(carIntroduction) {
                if (IsNull(carIntroduction)) {
                    alert("车辆简介不能为空");
                    return false;
                }
                if (!islength(carIntroduction, 0, 500)) {
                    alert("车辆简介最大只能有500个字符");
                    return false;
                }
                return true;
            }

            //验证购买须知
            function vfcNotes(purchaseNotes) {
                if (IsNull(purchaseNotes)) {
                    alert("购买须知不能为空");
                    return false;
                }
                if (!islength(purchaseNotes, 0, 1000)) {
                    alert("购买须知最大只能有1000个字符");
                    return false;
                }
                return true;
            }
        </script>
        <%=msBsc.WebUi.Code.QtHtmlGet.GetFloorHtml() %>
    </div>
</body>
</html>
